
// var UserInfo = require("UserInfo");
var UIManage = require("UIManage");

var getInfo = {code:null,nickName:null,avatarUrl:null,gender:null};
// var AppIDInfo = require("AppIDInfo");

cc.Class({
    extends: cc.Component,

    properties: {
        ChilrenView:cc.Sprite,
        WXSUB:cc.WXSubContextView,
        loadUI:cc.Node,
        Mask:cc.Node,
        SmallChilrenView:cc.Sprite,
        _updateFrae:0.1,
        _updateFrameCool:0.1,
        _version:105,//版本号

        _width:750,
        _height:1334,

        _Sence:0,
        _AppIDInfoList:[],
        
    },

   

    start () {
        UIManage.Instance.ShowGameStart();
        this._version = 105;
        this.isShow = false;
        this.closeUpdate = false;
        this.isAlreadyLogin = false;
        
    },

    getScreen()
    {

    },

    
    //获取后台信息
    C2G_GetUserInfo()
    {

    },
    
    IsShowButton(active)
    {
        if(this.button == null||this.button == undefined)
            return;
        if(active)
        {
            this.button.show();
        }
        else
        {   
            this.button.hide();
        }
    },

    Login(getInfo,self,isReqGameInfo = true)
    {
        // wx.login({
        //     success (res) {
        //         if (res.code) {
        //         getInfo.code = res.code
        //         //发起网络请求
        //         wx.request({
        //             url: 'https://xxx.qkxz.com/index.php?act=userinfo',
        //             data: {
        //             code: getInfo.code,
        //             nickName:getInfo.nickName,
        //             avatarUrl: getInfo.avatarUrl,
        //             gender:getInfo.gender,
        //             scene:self._Sence,
        //             //uid: self.key
        //             uid: self.OtherUID,
        //             },
        //             success (res) {
        //             self.isAlreadyLogin = true;//是否登录过
        //             var severuserinfo =  res.data.data;
                    
        //             self.playInfo.openid = severuserinfo.openid,
        //             self.playInfo.id = severuserinfo.id;
        //             self.playInfo.nickName = severuserinfo.nickName;
        //             self.playInfo.avatar_url = severuserinfo.avatar_url;
        //             self.playInfo.score = severuserinfo.score;
        //             self.IsGetUserInfo = true;
        //             if(isReqGameInfo)
        //             { 
        //                 self.C2G_GameInfo();
        //             }  
        //             //self.C2G_Redlog();
        //             },
        //             fail()
        //             {
        //                 self.HideMask();
        //                 wx.showToast({
        //                     title: "网络数据请求失败",
        //                     icon: 'success',
        //                     duration: 800
        //                 })
        //             }
        //         })
        //         } else {
        //             console.log('登录失败！' + res.errMsg)
        //         }  
        //     }
        // })
    },

    C2G_AppID()
    {

    },

    randomsort(a, b) {
        return Math.random()>.5 ? -1 : 1;
        //用Math.random()函数生成0~1之间的随机数与0.5比较，返回-1或1
    },

    SetAppItem()
    {
        // var AppIDInfoList = this._AppIDInfoList;
        
        // AppIDInfoList.sort(this.randomsort);
        
        // return AppIDInfoList;
    },

    C2G_GameStart()
    {

    },

    //C2G游戏结束
    C2G_GameOver(Score,level,action = null)
    {

    },

    C2G_GameInfo()
    {

    },

   

//红包钱数
    C2G_Redlog(action)
    {

    },
 
    // 显示好友排行
    ShowFrindRanking(IsRequ = true)
    {

    },
    
    ShowChildrenGameOver(score)
    {

    },

//重置子域的最大分数
    ResetChildMaxScore()
    {

    },

    ShowOne()
    {

    },

    ShowTwo()
    {

    },
    //提交分数
    SubmitScore(curscore,level)
    {
        // this.C2G_GameOver(curscore,level);
        

    },
    //打开子域
    ShowChild(isAlwaysShow = true)
    {   
        // if(isAlwaysShow == false)
        // {
        //     this.isShow = false;
        //     this.updateChild();
        //     this.WXSUB.enbale = false;
        // }
        // else
        // {
        //     this.isShow = true;
        //     this.WXSUB.enbale = true;
        // }
    },

    ShowSmallChild()
    {
    //     if (window.sharedCanvas != undefined&&window.sharedCanvas!=null) {
    //         this.tex.initWithElement(window.sharedCanvas);
    //         this.tex.handleLoadedTexture();
    //         this.ChilrenView.spriteFrame = new cc.SpriteFrame(this.tex);
    //     }
    //     this.SmallChilrenView.spriteFrame = this.ChilrenView.spriteFrame;
    //     this.SmallChilrenView.node.active = true;
    //     this.ChilrenView.node.active = false;
    //     this.isShow = false;
    },

    //关闭子域
    HideChild()
    {

    },

    update(dt)
    {
        // if(this.isShow == false)
        //     return;
        // this.updateChild();
    },

    updateChild()
    {
        // if (window.sharedCanvas != undefined&&window.sharedCanvas!=null) {
        //     this.tex.initWithElement(window.sharedCanvas);
        //     this.tex.handleLoadedTexture();
        //     this.ChilrenView.spriteFrame = new cc.SpriteFrame(this.tex);
        //     this.ChilrenView.node.active = true;
        //     this.SmallChilrenView.node.active = false;
        // }
    },
    
    associatedProgram(AppID,url,ID)
    {

    }, 

//告诉后台我打开了那个APP
    CG2_AppReqCount(ID)
    {

    },

    ShowMask()
    {
        this.Mask.active = true;
        this.loadUI.active = true;
        var m = cc.rotateBy(0.5, 180);
        var re = cc.repeatForever(m)
        this.loadUI.runAction(re);
    },

    HideMask()
    {
        this.Mask.active = false;
        this.loadUI.active = false;
    },

    //福利统计
    CG2_DailyWelfare()
    {       

    },

    CG2_ShareFriendList(action)
    {       

    },

    CG2_ShareFriendreg(action,id)
    {       

    },

    CG2_FDcount()
    {       

    },

});
